package crack.three_point_test;

import java.io.IOException;

import crack.AbstractThreePointTestUsingSDAElementDemo;

import math2.MathUtilities;
import fem2.AbstractStructuralCrackDemo;
import fem2.Element;
import fem2.MaterialModel;
import fem2.Mesh;
import fem2.MeshGenerator;
import fem2.MeshPart;
import fem2.Model;
import fem2.element.crack_sda.SOSConstantJumpCSTElement2;
import fem2.material.cohesive_law.CohesiveLaw;
import fem2.material.cohesive_law.Mode1LACohesiveLaw;
import fem2.pre_and_post.GidMeshGenerator;

public class ThreePointTestUsingSOSConstantJumpCSTElement2AndLACohesiveLaw extends
		AbstractThreePointTestUsingSDAElementDemo {

	public ThreePointTestUsingSOSConstantJumpCSTElement2AndLACohesiveLaw() {
		projectName = "three-point-test2.gid";
		meshFileName = "mesh1";
	}

	@Override
	public Mesh createMesh() {
		String fn = projectDir + '/' + projectName + '/' + meshFileName + ".msh";
		MeshGenerator mg = new GidMeshGenerator(fn);
		Mesh mesh = mg.getMesh(2);
		return mesh;
	}

	@Override
	public CohesiveLaw createCohesiveLaw(Model m) {
		double ft = 3.33;
		double Gf = 0.124;
		// double km = 30;
		double km = -1e5;
		double da = 0.015;
		double d0 = 0.16;
		double k = 0.5;
		return new Mode1LACohesiveLaw(Gf, ft, km, da, d0, k);
	}

	@Override
	public Element createElement(MeshPart mp, MaterialModel mm, CohesiveLaw cl) {
		Element e = new SOSConstantJumpCSTElement2(mp, mm, cl);
		e.setEchoLevel();
		return e;
	}

	public static void main(String[] args) throws IOException {

		AbstractStructuralCrackDemo sample = new ThreePointTestUsingSOSConstantJumpCSTElement2AndLACohesiveLaw();

		// double[] lambda = MyLinAlg.createLambdaArray(0.04, 0.0001, 0.041);

		// double[] lambda = MyLinAlg.createLambdaArray(0.04, 0.0001, 0.05);

		// double[] lambda = MyLinAlg.createLambdaArray(0.04, 0.0001, 0.1);

//		double[] lambda = MyLinAlg.createLambdaArray(0.04, 0.001, 0.2);
		
		double[] lambda = MathUtilities.createLambdaArray(0.04, 0.001, 0.5);

		sample.run(lambda);

	}

}
